package cn.wit.testalgorithms;

import java.util.Arrays;

/**
 * 数字转换为十六进制的数
 * 
 * @author 16604
 *
 */
public class DemoHex {
	public static void main(String[] args) {
		int hex = 100;
		toHex(hex);
	}

	public static StringBuilder toHex(int num) {
		StringBuilder r = new StringBuilder("");

		int count = 0;
		while (num > 16) {
			r.append(num % 16);
			num = (num - r.charAt(count)) / 16;
			count++;
		}
		r.append(num);

		for (int i = count; i >= 0; i--) {
			if (r.charAt(i) >= 10) {
				System.out.print(r.charAt(i) + " ");
			}
		}
		System.out.println(r);

		return r;
	}

}
